// Copyright 2022 jeff.li. and/or its affiliates.

#pragma once

#include <tbir/pipeline/jit_object.h>
#include <tbir/pipeline/op_kernel.h>
#include <tbir/runtime/module.h>

namespace tbir::runtime {

    // JitOp is a pipeline op with uniq function entry UserCodegenResource
    class JitOp : public OpKernel {
    public:
        void Init() override;

        int Bundle(string_view folder) override;

        RTValue Process(PyArgs inputs) const override;

        RTValue generic_call_attr(string_view func_name, PyArgs args);

        String GetHumanName(bool with_debug_info) const;

    protected:
        String main_func_name_;
        String jit_object_name_;
        std::shared_ptr<JitObject> jit_object_;
        NativeFunction forward_func_;
        const JitObject::FuncMeta *func_meta_ = nullptr;
        UserDataRef self_;

        friend class NativeObject;

        friend class UserDataRef;

        friend class UserDataNode;
    };

}  // namespace tbir::runtime
